// with polyfills
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/'
import i18n from './locales'
import { VueAxios } from './utils/request'
import ProLayout, { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
import themePluginConfig from '../config/themePluginConfig'
import bootstrap from './core/bootstrap'
import './core/lazy_use' // use lazy load components
import './permission' // permission control  // del permiss 开
import './utils/filter' // global filter
import './global.less' // global style
import '@/assets/css/font.css'
import vueSwiper from 'vue-awesome-swiper'
// import 'swiper/dist/css/swiper.css'
import 'swiper/swiper-bundle.css'
import { Collapse, FormModel, Pagination, Slider, Space } from 'ant-design-vue'
import VueClipboard from 'vue-clipboard2'
import Moment from 'moment'
import 'element-ui/lib/theme-chalk/index.css'
import {
  Backtop,
  Button,
  ButtonGroup,
  Card,
  Carousel,
  CarouselItem,
  Col,
  CollapseItem,
  ColorPicker,
  Divider,
  Icon,
  Image,
  Input,
  Loading,
  Option,
  OptionGroup,
  Radio,
  RadioButton,
  RadioGroup,
  Row,
  Select,
  Upload
} from 'element-ui'
import 'element-ui/lib/theme-chalk/base.css'
import CollapseTransition from 'element-ui/lib/transitions/collapse-transition'

Vue.use(Input)
Vue.use(Radio)
Vue.use(RadioGroup)
Vue.use(RadioButton)
Vue.use(Select)
Vue.use(Option)
Vue.use(OptionGroup)
Vue.use(Button)
Vue.use(ButtonGroup)
Vue.use(Icon)
Vue.use(Row)
Vue.use(Col)
Vue.use(Upload)
Vue.use(Card)
Vue.use(ColorPicker)
Vue.use(Divider)
Vue.use(Image)
Vue.use(Carousel)
Vue.use(CarouselItem)
Vue.use(Backtop)
Vue.use(CollapseItem)
Vue.component(CollapseTransition.name, CollapseTransition)
Vue.use(Loading.directive)

Vue.prototype.$loading = Loading.service
// mock
// WARNING: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.
// import './mock'
Vue.use(FormModel).use(Collapse).use(Space).use(Pagination).use(Slider)
// VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)
Vue.filter('dateFormat', function (dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
  return Moment(dataStr).format(pattern)
})
Vue.filter('getint', function (num) {
  return parseInt(num)
})
Vue.filter('getfloat', function (num) {
  if (String(num).indexOf('.') !== -1) {
    const arr = String(num).split('.')
    return arr[1]
  } else {
    return ''
  }
})
Vue.filter('getinterval', function (time1, time2) {
  const cha = Moment(time2).format('x') - Moment(time1).format('x')
  return Math.abs(cha / (24 * 3600 * 1000))
})
Vue.use(vueSwiper)
Vue.config.productionTip = false

// mount axios to `Vue.$http` and `this.$http`
Vue.use(VueAxios)
// use pro-layout components
Vue.component('pro-layout', ProLayout)
Vue.component('page-container', PageHeaderWrapper)
Vue.component('page-header-wrapper', PageHeaderWrapper)

window.umi_plugin_ant_themeVar = themePluginConfig.theme

new Vue({
  router,
  store,
  i18n,
  // init localstorage, vuex
  created: bootstrap,
  render: h => h(App)
}).$mount('#app')
